﻿<template>
    <div class="ad-content">
        <div class="ad-main">
            <div class="ad-console-top">
                <div class="ad-console-top-name">指标信息预警</div>
                <div class="ad-console-top-body">
                </div>
                <div class="ad-console-top-end">
                </div>
            </div>
            <div class="ad-console-body">
  
                <div class="ad-console-toolbar" v-if="IsAdmin">
                   <el-button type="primary" size="small" icon="icon-plus4 el-icon--left"  @click="refresh()">刷新</el-button>

                    <div style="float:right;">
                        <el-input v-model="searchkey" prefix-icon="el-icon-search" placeholder="请输入类别名称" @keyup.enter.native="search()" style="width:180px;" size="small"></el-input>
                        <el-button type="primary" size="mini" icon="icon-search el-icon--left" @click="search()" style="padding: 7px 10px;">搜索</el-button>
                    </div>
                </div>
                <div class="ad-card">
                    <el-table :data="list" size="mini" border style="width: 100%" @sort-change="handleSortChange">
                        <el-table-column type="selection" width="50" align="center"></el-table-column>
                        <el-table-column type="index" width="55" label="序号" align="center"></el-table-column>
                        <el-table-column prop="TaskName" label="任务名称" align="left"></el-table-column>
                        <el-table-column prop="LeaderUnitName" label="牵头单位" width="150" align="center"></el-table-column>
                        <el-table-column prop="UpCount" label="更新数量" align="left" width="150"></el-table-column>
                        <el-table-column label="操作" width="80" align="center" v-if="IsAdmin">
                            <template slot-scope="scope">
                                <el-button type="text" size="mini" @click="openDialog(scope.row.TaskID,scope.row.TaskName)">查看</el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                    <br />
                    <div style="text-align:center"><el-pagination v-if="count>0" background layout="prev, pager, next" :current-page="currentpage" :total="count" @current-change="pagerclick"></el-pagination></div>
                </div>
            </div>
            <el-dialog title="指标信息对比" class="dlg" v-dialogDrag :visible="showDialog" width="1200px" @close="closeDialog()">
                <div style="height:40px">  <el-button type="primary" size="small" icon="icon-refresh2 el-icon--left" @click="upNewsData()">更新当前数据</el-button></div>
                <h3> <i class="icon-flag3"></i>&nbsp;&nbsp;{{TaskInfo.TaskName}}</h3>
                <el-row :gutter="10">
                    <el-col :span="12">
                        <el-card class="box-card">
                            <el-form ref="formO" label-width="100px">
                                <h3>当前数据</h3>
                                <div v-for="Item in TaskInfo.data_O" class="box-card_item" v-if="Item.MsgList.length>0" >
                                    <el-form-item label-width="0px">
                                        <el-col :span="24">
                                            <el-form-item label="指标名称：" >
                                                {{Item.QuotaName}}     
                                                <el-popover placement="right" trigger="hover" >
                                                    <el-table :data="Item.MsgList">
                                                        <el-table-column min-width="150" property="ds" label="更新标识"></el-table-column>
                                                        <el-table-column min-width="400" property="Msg" label="具体情况"></el-table-column>
                                                    </el-table>
                                                    <i class="el-icon-question" slot="reference"></i>
                                                </el-popover>
                                            </el-form-item>
                                        </el-col>
                                    </el-form-item>
                                    <el-form-item label-width="0px">
                                        <el-col :span="24">
                                            <el-form-item label="更新标识：">
                                                {{Item.ds}}
                                            </el-form-item>
                                        </el-col>
                                    </el-form-item>
                                    <el-form-item label-width="0px">
                                        <el-col :span="12">
                                            <el-form-item label="当前值：">
                                                {{Item.CurrentValue}}
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12">
                                            <el-form-item label="目标值：">
                                                {{Item.TargetValue}}
                                            </el-form-item>
                                        </el-col>
                                    </el-form-item>
                                    <el-form-item label-width="0px">
                                        <el-col :span="12">
                                            <el-form-item label="起始值：">
                                                {{Item.StartValue}}
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12">
                                            <el-form-item label="值单位：">
                                                {{Item.ValueUnit}}
                                            </el-form-item>
                                        </el-col>
                                    </el-form-item>
                                    <el-form-item label-width="0px">
                                        <el-col :span="12">
                                            <el-form-item label="指标类型：">
                                                {{Item.QuotaType==1?'进度类指标':'监测类指标'}}
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12">
                                            <el-form-item label="值类型：">
                                                {{Item.ValueType==1?'正向':'负向'}}
                                            </el-form-item>
                                        </el-col>
                                    </el-form-item>
                                     <e-form-item label-width="0px">
                                         <el-col :span="24">
                                                 <table style="width: 100%" class="ele_normal" v-if="Item.QuotaType==1">
                                                     <thead v-if="Item.MList.length>0">
                                                         <tr>
                                                             <th>
                                                                 <div>时间</div>
                                                             </th>
                                                             <th v-for="(item,index) in Item.MList" :key="index" align="center">
                                                                 <div>{{item.MT}}</div>
                                                             </th>
                                                         </tr>
                                                     </thead>
                                                     <tbody>
                                                         <tr v-if="Item.MList.length>0">
                                                             <td>
                                                                 <div>目标值</div>
                                                             </td>
                                                             <td v-for="(item,index) in Item.MList" :key="index" align="center">
                                                                 <div>{{item.TargetValue}}</div>
                                                             </td>
                                                         </tr>
                                                         <tr>
                                                             <td>
                                                                 <div>计算口径</div>
                                                             </td>
                                                             <td align="center" :colspan="Item.MList.length">
                                                                 <div>{{Item.Calucation}}</div>
                                                             </td>
                                                         </tr>
                                                     </tbody>
                                                 </table>
                                                 <table style="width: 100%" class="ele_normal" v-if="Item.QuotaType==2">
                                                     <tbody>
                                                         <tr>
                                                             <td width="10%">
                                                                 <div>计算口径</div>
                                                             </td>
                                                             <td align="center" :colspan="Item.MList.length">
                                                                 <div>{{i.Calucation}}</div>
                                                             </td>
                                                         </tr>
                                                     </tbody>
                                                 </table>
                                
                                         </el-col>
                                    </e-form-item>



                                </div>
                            </el-form>
                        </el-card>
                    </el-col>
                    <el-col :span="12">

                        <el-card class="box-card">
                            <h3>最新数据</h3>
                            <el-form ref="formN" label-width="100px">
                                <div v-for="Item in TaskInfo.data_N" class="box-card_item">
                                    <el-form-item label-width="0px">
                                        <el-col :span="24">
                                            <el-form-item label="指标名称：">
                                                {{Item.QuotaName}}
                                            </el-form-item>
                                        </el-col>
                                    </el-form-item>
                                    <el-form-item label-width="0px">
                                        <el-col :span="24">
                                            <el-form-item label="更新标识：">
                                                {{Item.ds}}
                                            </el-form-item>
                                        </el-col>
                                    </el-form-item>
                                    <el-form-item label-width="0px">
                                        <el-col :span="12">
                                            <el-form-item label="当前值：">
                                                {{Item.CurrentValue}}
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12">
                                            <el-form-item label="目标值：">
                                                {{Item.TargetValue}}
                                            </el-form-item>
                                        </el-col>
                                    </el-form-item>
                                    <el-form-item label-width="0px">
                                        <el-col :span="12">
                                            <el-form-item label="起始值：">
                                                {{Item.StartValue}}
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12">
                                            <el-form-item label="值单位：">
                                                {{Item.ValueUnit}}
                                            </el-form-item>
                                        </el-col>
                                    </el-form-item>
                                    <el-form-item label-width="0px">
                                        <el-col :span="12">
                                            <el-form-item label="指标类型：">
                                                {{Item.QuotaType==1?'进度类指标':'监测类指标'}}
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12">
                                            <el-form-item label="值类型：">
                                                {{Item.ValueType==1?'正向':'负向'}}
                                            </el-form-item>
                                        </el-col>
                                    </el-form-item>
                                    <e-form-item label-width="0px">
                                        <el-col :span="24">
                                            <table style="width: 100%" class="ele_normal" v-if="Item.QuotaType==1">
                                                <thead v-if="Item.MList.length>0">
                                                    <tr>
                                                        <th>
                                                            <div>时间</div>
                                                        </th>
                                                        <th v-for="(item,index) in Item.MList" :key="index" align="center">
                                                            <div>{{item.MT}}</div>
                                                        </th>
                                                    </tr>
                                                </thead>
                                                <tbody>
                                                    <tr v-if="Item.MList.length>0">
                                                        <td>
                                                            <div>目标值</div>
                                                        </td>
                                                        <td v-for="(item,index) in Item.MList" :key="index" align="center">
                                                            <div>{{item.TargetValue}}</div>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td>
                                                            <div>计算口径</div>
                                                        </td>
                                                        <td align="center" :colspan="Item.MList.length">
                                                            <div>{{Item.Calucation}}</div>
                                                        </td>
                                                    </tr>
                                                </tbody>
                                            </table>
                                            <table style="width: 100%" class="ele_normal" v-if="Item.QuotaType==2">
                                                <tbody>
                                                    <tr>
                                                        <td width="10%">
                                                            <div>计算口径</div>
                                                        </td>
                                                        <td align="center" :colspan="Item.MList.length">
                                                            <div>{{i.Calucation}}</div>
                                                        </td>
                                                    </tr>
                                                </tbody>
                                            </table>

                                        </el-col>
                                    </e-form-item>



                                </div>
                            </el-form>
                        </el-card>
                    </el-col>
                </el-row>
            </el-dialog>
        </div>
    </div>
</template>
<script>
    export default {
        data() {
            return {
                list: [],
                showDialog: false,
                IsAdmin: false,
                ShowIndate: false,
                currentpage: 0,
                count:0,
                searchkey: '',
                TaskIDs: [],
                form: {
                    IntegralRuleID: 0,
                    Value: '',
                    Remark: ''
                },
                TaskInfo: {
                    TaskID: '',
                    TaskName:'',
                    data_O:[],
                    data_N:[]
                }

             
            }
        },
        mounted() {
            App.Page.init(this);
            this.load();
        },
        methods: {
            load() {
                App.Service.post("/plus/Yqd/QuotaMsg/GetList", { start: App.Fn.toStart(this.currentpage), limit: App.pagesize, searchkey: this.searchkey }).then((res) => {
                    if (res.success) {
                        this.IsAdmin = true;
                        this.count = res.totalcount;
                        this.list = res.data;
                    
                    }
                });
            },
            pagerclick(currentpage) {
                this.currentpage = currentpage;
                this.load();
            },
            search() {
                this.currentpage = 0;
                this.load();
            },
            refresh() {
                this.currentpage = 0;
                this.searchkey = 0;
                this.load();
            },
            openDialog(TaskID, TaskName) {
                App.Service.post("/plus/Yqd/QuotaMsg/GetTaskN_O", { TaskID: TaskID }).then((res) => {
                    if (res.success) {
                        this.TaskInfo.TaskID = TaskID
                        this.TaskInfo.TaskName = TaskName
                        this.TaskInfo.data_O = res.data_O
                        this.TaskInfo.data_N = res.data_N
                        this.showDialog = true
                        //this.IsAdmin = true;
                        //this.count = res.totalcount;
                        //this.list = res.data;

                    }
                });
            },
            closeDialog() {
                this.showDialog = false
                this.TaskInfo  = {
                    TaskID: '',
                    TaskName: '',
                    data_O: [],
                    data_N: []
                }
            },
            SelectionChange(val) {
                this.TaskIDs = val.map(row => row.TaskID);
          
            },
            upNewsData() {
                App.Page.confirm("您确认要更新当前记录吗? ", () => {
                    App.Service.post("/plus/Yqd/QuotaMsg/upNewsData", { TaskIDs: this.TaskInfo.TaskID }).then((res) => {
                        if (res.success) {
                            this.closeDialog();
                            this.load()
                        }
                    });
                });
                //App.Service.post("/plus/Yqd/QuotaMsg/GetList", { start: App.Fn.toStart(this.currentpage), limit: App.pagesize, searchkey: this.searchkey }).then((res) => {
                //    if (res.success) {
                //        this.IsAdmin = true;
                //        this.count = res.totalcount;
                //        this.list = res.data;

                //    }
                //});

            }

        }
    };
</script>
